﻿						<div class="box border green">
									<div class="box-title">
										<h4><i class="fa fa-table"></i>角色列表</h4>
										<div class="tools hidden-xs">
											<a href="#box-config" data-toggle="modal" class="config">
												<i class="fa fa-cog"></i>
											</a>
											<a href="javascript:;" class="reload">
												<i class="fa fa-refresh"></i>
											</a>
											<a href="javascript:;" class="collapse">
												<i class="fa fa-chevron-up"></i>
											</a>
											<a href="javascript:;" class="remove">
												<i class="fa fa-times"></i>
											</a>
										</div>
									</div>
									<div class="box-body">
										<form action="index.php?c=role&a=del&admin=1" method="post" >

										<table id="" cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered table-hover">
											<thead>
												<tr>
													<th class="width-1 center" width="80" >
														全选
														<div class="checker" style="float:right;margin-right:4px;"><span><input type="checkbox" name="all"></span></div>

													</th>
													<th >#</th>
													<th>角色名称</th>
													<th>权限</th>
													<th>状态</th>
													<th>操作</th>

												</tr>
											</thead>
											<tbody>
												<?php
													if(!empty($data)){
													foreach($data as $v){?>
													<tr class="gradeX">
														<td class="center">
															<div class="checker" style="float:right;margin-right:4px;"><span><input type="checkbox" class="ckbox" name="checked[]" value="<?php echo $v['id']?>"></span></div>
														</td>
														<td id="id"><?php echo $v['id']?></td>
														<td id="name"><?php echo $v['name']?></td>
														<td class="hidden-xs exdit" co="<?php echo 'content'?>" >
														<?php foreach($v['ch'] as $k):
                                                               echo $k['name'].' ';
                                                               endforeach;
															?>

														</td>
														<td class="status hidden-xs"><?php  echo ($v['status']==0)?"未启用":"启用" ?></td>
														<td class="center hidden-xs" style="width:160px">
															<a href="index.php?c=role&a=edit&admin=1&id=<?php echo $v['id']?>" class="btn btn-info"><i class="fa fa-pencil-square-o"></i>编辑</a>
															<a class="btn btn-danger" href="index.php?c=role&a=del&id=<?php echo $v['id']?>" onclick="return confirm('确定要删除吗');"><i class="fa fa-trash-o"></i>删除</a>
														</td>
													</tr>
												<?php }}?>
											</tbody>

										</table>

										<button class='btn btn-danger' type="submit" onclick="return confirm('确定要删除吗');"><i  class='fa fa-trash-o' id="del">批量删除</i></button>



										</form>
										<div class="row">
											<div class="col-sm-12">
												<div class="pull-left">
													<div class="dataTables_info" id="datatable1_info">Showing 1 to 9 of 9 entries</div>
												</div>
												<div class="pull-right">
												    <div class="dataTables_paginate paging_bs_full" id="datatable1_paginate">
												   		<ul class="pagination">

									   					</ul>
								   					</div>
												</div>
												<div class="clearfix"></div>
											</div>
										</div>
									</div>
								</div>

<script src="resources/admin/js/jquery/jquery-2.0.3.min.js"></script>
<script type="text/javascript">

/*点击增加一行*/
			$('form').on('click','#add',function(){
				var rows = '';
				rows+='<tr class="gradeX">';
				rows+='<td class="center">';
				rows+='<div class="checker" style="float:right;margin-right:4px;"><span><input type="checkbox" class="ckbox" name="checked[]" value=""></span></div>';
				rows+="</td>";
				rows+="<td id='id'></td>";
				rows+="<td class='exdit' co='addtitle'></td>";

				rows+="<td class='exdit' co='addcontent'></td>";

				rows+="<td class='center status hidden-xs'> </td>";
				rows+="<td class='center hidden-xs' style='width:160px'>";
				rows+="<a class='btn btn-light-grey save' href='index.php?c=news&a=list&admin=1'><i class='fa fa-pencil-square-o'></i>保存</a>";
				rows+="<button type='button' class='btn btn-light-grey cancle'><i class='fa fa-trash-o'></i>取消</button></td></tr>";

				/*在tbody下找到第一个tr在它之前添加标签*/
				$('tbody').find('tr').first().before(rows);

				/*抓取保存按钮*/
				$('.save').click(function(){

					var rand = Math.random(0,5);

					$.ajax({
						url: 'index.php?c=news&a=list&admin=1&ss='+rand,
						type: 'get',
						data: {
							'title':$("td[co=addtitle]").text(),
							'content':$("td[co=addcontent]").text(),
							'type':$("td[co=addtype]").text()
						}
					})


				})
				/*抓取 取消按钮删除增加的一行*/
				$('.cancle').click(function(){
					$('tbody').find('tr').first().remove();
				})

		})
/*/点击增加一行*/

/*批量选中删除功能*/
	$(function(){
	/*点击全选时，所有子选项选中*/
	$('input[name=all]').click(function(){

		//所有子选项选中 this.checked是当前操作标签的checked属性
		$('.ckbox').prop("checked",this.checked);



	})
		//点击子选项时
		$('.row').on('click','.ckbox',function(){

		//当所有子选项的长度等于选中状态的子选项长度时，给全选，选中
		if($('.ckbox').length==$('.ckbox:checked').length){
			$('input[name=all]').prop('checked',this.checked);

		}
		if($('.ckbox').length!=$('.ckbox:checked').length){
			$('input[name=all]').prop('checked',false);

		}
		//$('pagination').on('click','.fly',function(){$('input[name=all]').prop('checked',false);})
	})

	//       if($(this).prop('checked')==true){

		//  $('.ckbox').prop("checked",true);
	//       }else{
		// $('.ckbox').prop("checked",false);
	//       }
	//
/*/批量选中删除功能*/






})

</script>